home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
progem.lzh
/
wind9.prf
< prev
Wrap
Text File
|
1987-06-23
|
21KB
|
482 lines
.!****************************************************************************
.!
.! ANTIC PUBLISHING INC., COPYRIGHT 1985. REPRINTED BY PERMISSION.
.!
.! ** Professional GEM ** by Tim Oren
.!
.! Proff File by ST enthusiasts at
.! Case Western Reserve University
.! Cleveland, Ohio
.! uucp : decvax!cwruecmp!bammi
.! csnet: bammi@case
.! arpa : bammi%case@csnet-relay
.! compuserve: 71515,155
.!
.!****************************************************************************
.!
.!
.!****************************************************************************
.!
.! Begin Part 9
.!
.!****************************************************************************
.!
.PART IX VDI Graphics: Lines and Solids
.PP
This issue of ST PRO GEM is the first in a series of two
which will explore the fundamentals of VDI graphics output. In
this installment, we will take a look at the commands necessary to
output simple graphics such as lines, squares and circles as well
as more complex figures such as polygons. The following episode
will take a first look at graphics text output, with an emphasis
on ways to optimize its drawing speed. It will also include
another installment of ONLINE Feedback. As usual, there is a
download with this column. You should find it under the name
GEMCL9.C in DL3 of ATARI16 (PCS-58).
.SH A BIT OF HISTORY
One of the reasons that the VDI can be confusing is that
drawing anything at all, even a simple line, can involve setting
around four different VDI parameters before making the draw call!
(Given the state of the GEM documents, just FINDING them can be
fun!) Looking backwards a bit sheds some light on why the VDI is
structured this way, and also gives us a framework for organizing
a discussion of graphics output.
.PP
The GEM VDI closely follows the so-called GKS standard, which
defines capabilities and calling sequences for a standardized
graphic input/output system. GKS is itself an evolution from an
early system called "Core". Both of these standards were born in
the days when pen plotters, vectored graphics displays, and
minicomputers were the latest items. So, if you wonder why
setting the drawing pen color is a separate command, just think
back a few years when it actually meant what it says! (The
cynical may choose instead to ponder the benefits of
standardization.)
.PP
When doing VDI output, it helps if you pretend that the
display screen really is a plotter or some other separate device,
which has its own internal parameters which you can set up and
read back. The class of VDI commands called Attribute Functions
let you set the parameters. Output Functions cause the "device"
to actually draw someone once it is configured. The Inquire
Functions let you read back the parameters if necessary.
.PP
There are two parameters which are relevant no matter what
type of object you are trying to draw. They are the writing mode
and the clipping rectangle. The writing mode is similar to that
discussed in the column on raster operations. It determines what
effect the figure you are drawing will have on data already on the
screen. The writing mode is set with the call:
.FB vswr_mode()
vswr_mode(vdi_handle, mode);
.FE
Vdi_handle, here and below, is the handle obtained from
graf_handle at the beginning of the program. Mode is a word which
may be one of:
.sp 1
.in +8
1 - Replace Mode
.br
2 - Transparent Mode
.br
3 - XOR mode
.br
4 - Reverse Transparent Mode
.in -8
.PP
In replace mode, whatever is on the screen is overwritten.
If you are writing characters, this means the background of each
character cell will be erased.
.PP
In transparent mode, only the pixels directly under the
"positive" part of the image, that is, where 1-bits are being
written, will be changed. When writing characters, the background
of the cell will be left intact.
.PP
In XOR mode, an exclusive or is performed between the screen
contents and what is being written. The effect is to reverse the
image under areas where a 1-bit occurs.
.PP
Reverse transparent is like transparent, but with a "reverse
color scheme". That is, only places where a 0-bit is to be
put are changed to the current writing color. When you
write characters in reverse transparent (over white), the effect
is reverse video.
.PP
The other common parameter is the clipping rectangle. It
defines the area on the screen where the VDI is permitted to draw.
Any output which would fall outside of this area is ignored; it is
effectively a null operation. The clip rectangle is set with the
call:
.FB vs_clip()
vs_clip(vdi_handle, flag, pxy);
.FE
Pxy is a four-word array. Pxy[0] and pxy[1] are the X and Y
screen coordinates, respectively, of one corner of your clipping
rectangle. Pxy[2] and pxy[3] are the coordinates of the
diagonally opposite corner of the rectangle. (When working with
the AES, use of a GRECT to define the clip is often more
convenient. The routine set_clip() in the download does this.)
.PP
Flag is set to TRUE if clipping is to be used. If you set it
to FALSE, the entire screen is assumed to be fair game.
.PP
Normally, you should walk the rectangle list for the current
window to obtain your clipping rectangles. (See ST PRO GEM #2 for
more details.) However, turning off the clip speeds up all output
operations, particularly text. You may do this ONLY when you are
absolutely certain that the figure you are drawing will not extend
out of the top-most window, or out of a dialog.
.SH THE LINE FORMS ON THE LEFT
The VDI line drawing operations include polyline, arc,
elliptical arc, and rounded rectangle. I'll first look at the
Attribute Functions for line drawing, then go through the drawing
primitives themselves.
.PP
The most common used line attributes are color and width.
The color is set with:
.FB vsl_color()
vsl_color(vdi_handle, color);
.FE
where color is one of the standard VDI color indices, ranging
from zero to 15. (As discussed in column #6, the color which
actually appears will depend on the pallette setting of your ST.)
.PP
The line width may only be set to ODD positive values, for
reasons of symmetry. If you try to set an even value, the VDI
will take the next lower odd value. The call is:
.FB vsl_width()
vsl_width(vdi_handle, width);
.FE
The two less used line parameters are the end style and
pattern. With the end style you can cause the output line to
have rounded ends or arrowhead ends. The call is:
.FB vsl_ends()
vsl_ends(vdi_handle, begin_style, end_style);
.FE
Begin_style and end_style are each words which may have the
values zero for square ends (the default), one for arrowed ends,
or two for rounded ends. They determine the styles for the
starting and finishing ends of the line, respectively.
.PP
The line pattern attribute can select dotted or dashed lines
as well as more complicated patterns. Before continuing, you
should note one warning: VDI line output DOES NOT compensate for
pixel aspect ratio. That is, the dashes on a line will look twice
as long drawn vertically on a medium-res ST screen as they do when
drawn horizontally. The command for setting the pattern is:
.FB vsl_type()
vsl_type(vdi_handle, style);
.FE
Style is a word with a value between 1 and 7. The styles
selected are:
.sp 1
.in +8
1 - Solid (the default)
.br
2 - Long Dash
.br
3 - Dot
.br
4 - Dash, Dot
.br
5 - Dash
.br
6 - Dash, Dot, Dot
.br
7 - (User defined style)
.in -8
.PP
The user defined style is determined by a 16-bit pattern
supplied by the application. A one bit in the pattern turns a
pixel on, a zero bit leaves it off. The pattern is cycled through
repeatedly, using the high bit first. To use a custom style, you
must make the call:
.FB vsl_udsty()
vsl_udsty(vdi_handle, pattern);
.FE
before doing vsl_type().
.PP
As I mentioned above, the line type Output Functions
available are polyline, circular and ellliptical arc, and rounded
rectangle. Each has its own calling sequence